<template>
  <div id="addTw">
    <div class="addTw">
      <el-input v-model="inputTw" placeholder="请输入打字机" />
      <div class="btn">
        <el-button type="primary" @click="addTw">新增打字机</el-button>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ElMessage } from "element-plus";
import { ref } from "vue";
import { twAdd } from "../../../../api/index/tw";
//调用父组件定义
const emit = defineEmits(["addSuccess"]);
//绑定数据
const inputTw = ref("");
//添加成功
const addTw = () => {
  const param = {
    twText: inputTw.value,
  };
  twAdd(param).then((res) => {
    ElMessage({
      type: "success",
      message: res + "",
    });
    emit("addSuccess"); //调用父组件,创建成功
  });
};
</script>

<style lang="less" scoped>
#addTw {
  width: 100%;
  height: 100%;
  .addTw {
    :deep(.el-input__wrapper) {
      --el-input-focus-border-color: aqua;
      background-color: rgb(27, 44, 92);
      .el-input__inner {
        color: white;
        &::-webkit-input-placeholder {
          /* WebKit browsers*/
          color: rgba(aqua, 0.5);
        }
      }
    }
    .btn {
      margin-top: 5%;
      margin-left: 75%;
      :deep(.el-button--primary) {
        margin-bottom: 5%;
        --el-button-bg-color: none;
        --el-button-border-color: rgba(aqua, 0.8);
        --el-button-hover-text-color: black;
        --el-button-hover-bg-color: rgba(aqua, 0.8);
        --el-button-hover-border-color: rgba(aqua, 0.8);
      }
    }
  }
}
</style>
